<template>
  <div id="comment" v-if="Object.keys(commentInfo).length !== 0">
    <div class="comment-top">
      <span>用户评价</span>
      <span><a href="javascript:">更多 >></a></span>
    </div>
    <div class="comment-content">
      <div class="user">
        <img class="user-img" :src="commentInfo.user.avatar" alt="" />
        <span class="user-name">{{ commentInfo.user.uname }}</span>
      </div>
      <div class="msg">
        <div class="msg-content">{{ commentInfo.content }}</div>
        <div class="msg-other">
          <span>{{ commentInfo.created | dateFormat }}</span>
          <span>{{ commentInfo.style }}</span>
        </div>
      </div>
      <div class="img" v-if="commentInfo.images">
        <img
          :src="commentInfo.images[0]"
          alt=""
          @click="imgClick(commentInfo.images[0])"
        />
      </div>
    </div>
  </div>
</template>

<script>
import { dateFormat } from "@/common/utils";

export default {
  name: "detailCommentInfo",
  props: {
    commentInfo: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  methods: {
    imgClick(src) {
      this.$parent.imgClick(src);
    },
  },
  filters: {
    dateFormat(value) {
      const time = new Date(value * 1000);
      return dateFormat(time, "yyyy/MM/dd  hh:mm");
    },
  },
};
</script>

<style scoped>
#comment {
  border-top: 3px solid #e5e4e4;
  border-bottom: 3px solid #e5e4e4;
  padding-bottom: 10px;
  margin-bottom: 10px;
}
.comment-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 30px 15px 10px;
  font-size: 14px;
  border-bottom: 1px solid #e5e4e4;
}
.comment-top a {
  color: #333;
  text-decoration: none;
}
.user {
  padding: 15px 0 15px 10px;
  display: flex;
  align-items: center;
}
.user .user-img {
  width: 45px;
  border-radius: 50%;
  margin-right: 10px;
}
.user .user-name {
  font-size: 14px;
}
.msg {
  padding-left: 10px;
  padding-right: 20px;
}
.msg-content {
  font-size: 14px;
  margin-bottom: 10px;
}
.msg-other {
  margin-bottom: 10px;
}
.msg-other span {
  padding-right: 20px;
  color: #615858;
}
.img {
  padding-left: 10px;
}
.img img {
  height: 90px;
}
</style>
